﻿using System;

namespace LoongEgg.Check
{
    /// <summary>
    /// byte和byte[]的扩展方法
    /// </summary>
    public static class byteExtensions
    {
        /// <summary>
        /// byte[] -> UInt64
        /// </summary>
        public static UInt64 ToUInt64(this byte[] self)
        {
            UInt64 ret = 0;
            int i = self.Length - 1;
            while (i > 0)
            {
                ret |= self[i];
                ret <<= 8;
                i -= 1;
            }

            ret |= self[0];
            return ret;
        }
    }
}
